home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / ADULT6.ZIP / ADULT6.ASM next >
Assembly Source File  |  1995-05-31  |  28KB  |  701 lines

  1. ;       FULL VERSION  V1.6 DECRYPTING INCLUDED. (ADULT CHANNEL ONLY)
  2.  
  3. ;       WARNING:: THIS PROGRAM MUST NOT BE USED OR COPIED IN 
  4. ;                 ANY WAY, OTHER THAN FOR SELF EDUCATIONAL PURPOSES
  5. ;                 IN PROGRAMMING. USE OF THIS PROGRAM FOR FREE SKY
  6. ;                 VIEWING IS ILLEGAL!.
  7.  
  8.  
  9.     ;   setup all data memory address pointers
  10.     
  11.     ;   locations used for MAIN and COMMS routeen.
  12.  
  13.         MEMRST  EQU     0900H   ;answer on reset message from card address 
  14.         MEM7C   EQU     0910H   ;info from card to decoder                             
  15.         MEM72   EQU     0920H   ;prevous card info from decoder to card
  16.         MEM70   EQU     0930H   ;issue no. of card to decoder
  17.         MEM78   EQU     0940H   ;hash gen value out to decoder 8 bytes
  18.         MEM74   EQU     0950H   ;hash gen value in to the card 32 bytes
  19.         MEM7A   EQU     0970H   ;on screen text to decoder
  20.     MEMCOMMAND  EQU     0990H   ;command class from decoder (5 bytes)
  21.     
  22.     ;   locations used by the DECODE ALGORYTM routeen.
  23.  
  24. ;memory locations for various data sections.
  25. answ            equ     mem78                  ;set answ base address        
  26. msg             equ     mem74                  ;set msg base address
  27. display         equ     0a40h                  ;set display memory
  28. comments        equ     0a70h                  ;set comments memory
  29. errortext       equ     0e50h                  ;set errortext memory
  30. parms           equ     080h                   ;parameter PSP memory
  31. keytab          EQU     09a0H                  ;start of keys   
  32. comport         equ     answ+8                 ;comport number
  33.  
  34.  
  35. ;kernel register locations.
  36.  
  37.         REGS       equ 0fe0h   ;start of registers
  38.         var        equ regs    ;
  39.         oi         equ regs+1  ;
  40.         in         equ regs+2  ;
  41.         status     equ regs+3  ;
  42.         key        equ regs+4  ;
  43.         b          equ regs+5  ;
  44.  
  45.  
  46.         ;waste time between bytes
  47.  
  48.         STOP_TIME  EQU  0400h
  49.  
  50.  
  51.        code    segment 
  52.        org 100h 
  53.        assume cs:code,ds:code 
  54.                  
  55. ;        ************   PROGRAM STARTS HERE    ****************
  56.  
  57. ;This section tests for valid parameter setup.
  58.  
  59. init:   mov bx,0                ;pointer = 0
  60.         mov al,parms[bx]        ;get first byte in PSP
  61.         cmp al,0                ;test for 00h
  62.         jnz p_ok                ;if <> 0 jmp p_ok and continue
  63.         
  64.         mov di,0                ;set pointer to 0
  65.         mov ah,09               ;request display
  66.         lea dx,errortext[di]    ;set pointer to 'errortext' memory
  67.         int 21h                 ;call DOS to diplay errortext
  68.         mov ax,0                ;request exit
  69.         int 21h                 ;exit to dos after displaying ERROR message
  70. p_ok:
  71.  
  72. ;This section initialises the com port.
  73.  
  74.         mov bx,0                ;pointer = 0
  75.         mov dl,parms[bx+2]      ;get com number from parm memory
  76.         sub dl,31h              ;convert number into com value (0-3)
  77.         mov comport[bx],dl      ;save updated value of com port
  78.         mov dh,0                ;setup dx for the com port value
  79.         mov ah,00               ;request for init port
  80.         mov al,11101111b        ;set parameters 9600,o,8,2 
  81.     int 14h                 ;call bios com routeen 
  82.  
  83. ;This section initialises the text mode (on or off).
  84.  
  85.         mov bx,0                ;pointer = 0
  86.         mov al,parms[bx+3]      ;get the text command from parm memory
  87.         cmp al,"T"              ;test for "T" (text on)
  88.         jz text_on              ;if set jmp text_on
  89.         cmp al,"t"              ;test for "t" (text on)
  90.         jz text_on              ;if set jmp text_on
  91.         mov al,0c0h             ;set text mode to off
  92.         mov mem7a[bx],al        ;update text memory
  93.         jmp end_t_parm          ;
  94. text_on:
  95.         mov al,0d8h             ;set text mode to on 24 chars
  96.         mov mem7a[bx],al        ;update text memory
  97. end_t_parm:
  98.  
  99.         call diswords           ;call the PC display routeen to show comments.
  100.  
  101. init1:
  102.     call reset              ;call the reset testing routeen.
  103.  
  104. main:                           ;this is the main function operating on
  105.                 ;the commands as they come in.
  106.  
  107.     call getinst            ;get an instruction from decoder        
  108.         call test_key
  109.         call textupdate         ;call status checking & display it.
  110.     mov bx,01               ;set pointer to instruction byte in memory
  111.     mov al,memcommand[bx]   ;load the instruction byte into al        
  112.     cmp al,00               ;test for missing instruction
  113.     jz init1                ;if missing start from init1
  114.     
  115.     cmp al,70h              ;test for 70
  116.     jz j70                  ;
  117.     cmp al,72h              ;test for 72
  118.     jz j72                  ;
  119.     cmp al,74h              ;test for 74
  120.     jz j74                  ;
  121.     cmp al,76h              ;test for 76
  122.     jz j76                  ;
  123.     cmp al,78h              ;test for 78
  124.     jz j78                  ;
  125.     cmp al,7ah              ;test for 7a
  126.     jz j7a                  ;
  127.     cmp al,7ch              ;test for 7c
  128.     jz j7c                  ;
  129.     cmp al,7eh              ;test for 7e
  130.     jz j7e                  ;
  131.     cmp al,80h              ;test for 80
  132.     jz j80                  ;
  133.     cmp al,82h              ;test for 82
  134.     jz j82                  ;
  135.      
  136.     jmp init1               ;this jmp should never be reached!
  137.                 ;but its here all the same.
  138.                 
  139. ;vector list for procedures:-
  140.  
  141. j70:    call p70
  142.     jmp main
  143. j72:    call p72
  144.     jmp main
  145. j74:    call p74
  146.     jmp main
  147. j76:    call p76
  148.     jmp main
  149. j78:    call p78
  150.     jmp main
  151. j7a:    call p7a
  152.     jmp main
  153. j7c:    call p7c
  154.     jmp main
  155. j7e:    call p7e        
  156.     jmp main
  157. j80:    call p80
  158.     jmp main
  159. j82:    call p82
  160.     jmp main
  161.  
  162.  
  163. ;******* various routeens follow:-  *********
  164.  
  165. send:                           ;send one byte using the AH reg.
  166.         push bx                 ;save value of bx
  167.     not ah                  ;invert the data byte 
  168.     mov dl,8                ;set reverse bits loop to 8 bits   
  169. ls:     rcl ah,1                ;rotate ah data byte left into carry 
  170.     rcr dh,1                ;rotate carry into dh result reversed. 
  171.     dec dl                  ;dl=dl-1 
  172.     jnz ls                  ;if not completed continue rotating. 
  173.                 ;byte reversed & inverted, now send it. 
  174.     mov al,dh               ;copy result byte in sending reg. al 
  175.         mov bx,0                ;pointer = 0
  176.         mov dx,comport[bx]      ;direct to com port
  177.         mov ah,01h              ;request for tx to com port
  178.     int 14h                 ;call bios tx routeen  
  179. not_tx:                         ;this next section waits until tx is done.
  180.         mov bx,0                ;pointer = 0
  181.         mov dx,comport[bx]      ;load the com number into dx
  182.         mov ah,03               ;request status of port
  183.         int 14h                 ;call the bios status routeen
  184.         and ah,01000000b        ;test for tx shift register is empty.
  185.         jz not_tx               ;if bit 0 set of status, wait.
  186.         mov cx,stop_time        ;waste some time to extend stop bits!
  187. pad:    loop pad                ;loop
  188.         pop bx                  ;restore value of bx
  189.         ret                     ;byte now sent, return
  190.  
  191.  
  192. getb:                           ;get one byte, result is in AH reg.
  193.         push bx                 ;save value of bx
  194.         mov bx,0                ;pointer = 0
  195.         mov dx,comport[bx]      ;set com port no.
  196.         mov ah,02               ;request rx byte from bios routeen
  197.     int 14h                 ;call the bios comms routeen, data in al        
  198.     not al                  ;invert the data byte 
  199.     mov dl,8                ;set reverse bits loop to 8 bits   
  200. lg:     rcl al,1                ;rotate al data byte left into carry 
  201.     rcr dh,1                ;rotate carry into dh result reversed. 
  202.     dec dl                  ;dl=dl-1 
  203.     jnz lg                  ;if not completed continue rotating. 
  204.                 ;byte reversed & inverted now ready 
  205.     mov ah,dh               ;copy result byte in rx reg ah 
  206.         pop bx                  ;restore bx
  207.         ret                     ;return
  208.  
  209. textupdate:                     ;display memory is updated depending
  210.                 ;on the STATUS bits 1 & 2.
  211.     mov bx,0
  212.     mov al,msg[bx]          ;get the msg[0] (scrambled or soft) byte
  213.     and al,11110000b        ;mask out low nibble
  214.     cmp al,11000000b        ;test for unscrambled or soft encyption
  215.     jnz test_st
  216.                 ;soft encryption detected
  217.     mov ah,"X"
  218.     mov mem7a[bx+7],ah      ;text = 'X' for both test
  219.     mov mem7a[bx+19],ah
  220.     jmp textret             ;bypass status testing
  221.  
  222. test_st:
  223.     mov al,status[bx]       ;get the status byte into al
  224.     mov dl,al               ;test bit 1 of status
  225.     and dl,1
  226.     jz sig0
  227.     mov ah,"1"
  228.     mov mem7a[bx+7],ah      ;store '1' in sig text memory
  229.     jmp bit2
  230. sig0:   mov ah,"0"
  231.     mov mem7a[bx+7],ah      ;store '0' in sig text memory
  232.     
  233. bit2:   mov dl,al               ;test bit 2 of status
  234.     and dl,2
  235.     jz crc0
  236.     mov ah,"1"
  237.     mov mem7a[bx+19],ah     ;store '1' in crc text memory
  238.     jmp textret
  239. crc0:   mov ah,"0"
  240.     mov mem7a[bx+19],ah     ;store '0' in crc text memory
  241. textret:
  242.     ret
  243.  
  244. getinst:                        ;this routeen gets a command from
  245.                 ;the decoder. The resulting bytes of
  246.                 ;the header are placed in memcommand. 
  247.                 ;if there is no command, then result = 00.
  248.     
  249.     call getb               ;clear the echo rx byte
  250.     call getb               ;get a byte 
  251.     cmp ah,53h              ;test if its a command 53h
  252.     jnz ins00               ;if not ins=00
  253.                 ;got it! now update the command memory
  254.     mov bx,0                ;set index mem pointer to 0
  255.     mov memcommand[bx],ah   ;put the 53h into command memory (optional)
  256.     inc bx                  ;index pointer +1
  257. get:    call getb               ;get the next data
  258.     mov memcommand[bx],ah   ;put into command memory
  259.     inc bx                  ;index pointer +1
  260.     cmp bx,05h              ;have 5 chars been stored?
  261.     jnz get                 ;if not get another one
  262.     jmp ok                  ;all received so return
  263. ins00:  mov ah,00               ;set the result ins to 00
  264.     mov bx,01               ;pointer to ins byte in memcommand
  265.     mov memcommand[bx],ah   ;store the byte
  266. ok:     ret                     ;return                         
  267.  
  268.  
  269. ;*******   procedure routeens follow:-  *********
  270.  
  271.  
  272.                 ;SEND ID NUMBER AND CARD INFO TO DECODER.
  273. p70:    mov ah,70h              ;send procedure byte 70h
  274.     call send               ;call the send routeen
  275.     mov bx,0                ;reset the memory pointer
  276. p70l:   mov ah,mem70[bx]        ;get a byte from memory to send
  277.     call send               ;call the send byte routeen
  278.     inc bx                  ;bx=bx+1
  279.     cmp bx,06               ;test for 6 bytes sent yet
  280.     jnz p70l                ;if not finished then get another one
  281.     call endproc            ;call the end of procedure routeen
  282.     ret
  283.  
  284.                 ;PREVIOUS CARD INFO VIA DECODER.
  285. p72:    mov ah,72h              ;send procedure byte 72h
  286.     call send               ;call the send routeen
  287.     mov bx,0                ;reset the memory pointer
  288.     call getb               ;clear echo from rx buffer
  289. p72l:   call getb               ;call the getbyte routeen
  290.     mov mem72[bx],ah        ;put ah data into memory
  291.     inc bx                  ;bx=bx+1
  292.     cmp bx,10h              ;test for 16 bytes sent yet
  293.     jnz p72l                ;if not finished then get another one
  294.     call endproc            ;call the end of procedure routeen
  295.     ret
  296.  
  297.                 ;32 BYTES OF STATION MESSAGE FROM DECODER.
  298. p74:    mov ah,74h              ;send procedure byte 74h
  299.     call send               ;call the send routeen
  300.     mov bx,0                ;reset the memory pointer
  301.     call getb               ;clear echo from rx buffer
  302. p74l:   call getb               ;call the getbyte routeen
  303.     mov mem74[bx],ah        ;put ah data into memory
  304.     inc bx                  ;bx=bx+1
  305.     cmp bx,20h              ;test for 32 bytes sent yet
  306.     jnz p74l                ;if not finished then get another one
  307.     call endproc            ;call the end of procedure routeen
  308.     ret
  309.  
  310.                 ;AUTHORISE BUTTON PRESSED FROM DECODER.
  311. p76:    mov ah,76h              ;send procedure byte 76h 
  312.     call send               ;call the send routeen
  313.     call endproc            ;call the end of procedure routeen
  314.     mov ax,0                ;now EXIT to dos.
  315.     int 21h                 
  316.  
  317.                 ;SEND 8 BYTE ANSWER TO DECODER.
  318. p78:    call decrypt            ;CALL THE DECRYPTING ROUTEEN NOW.
  319.     mov ah,78h              ;send procedure byte 78h
  320.     call send               ;call the send routeen
  321.     mov bx,0                ;reset the memory pointer
  322. p78l:   mov ah,mem78[bx]        ;get a byte from memory to send
  323.     call send               ;call the send byte routeen
  324.     inc bx                  ;bx=bx+1
  325.     cmp bx,08               ;test for 8 bytes sent yet
  326.     jnz p78l                ;if not finished then get another one
  327.     call endproc            ;call the end of procedure routeen
  328.     ret
  329.  
  330.                 ;SEND ON SCREEN TEXT MESSAGE TO DECODER.
  331. p7a:    mov ah,7ah              ;send procedure byte 7ah
  332.     call send               ;call the send routeen
  333.     mov bx,0                ;reset the memory pointer
  334. p7al:   mov ah,mem7a[bx]        ;get a byte from memory to send
  335.     call send               ;call the send byte routeen
  336.     inc bx                  ;bx=bx+1
  337.     cmp bx,25               ;test for 25 bytes sent yet
  338.     jnz p7al                ;if not finished then get another one
  339.     call endproc            ;call the end of procedure routeen
  340.     ret
  341.  
  342.                 ;SEND CARD INFO TO DECODER.
  343. p7c:    mov ah,7ch              ;send procedure byte 7ch
  344.     call send               ;call the send routeen
  345.     mov bx,0                ;reset the memory pointer
  346. p7cl:   mov ah,mem7c[bx]        ;get a byte from memory to send
  347.     call send               ;call the send byte routeen
  348.     inc bx                  ;bx=bx+1
  349.     cmp bx,10h              ;test for 16 bytes sent yet
  350.     jnz p7cl                ;if not finished then get another one
  351.     call endproc            ;call the end of procedure routeen
  352.     ret
  353.  
  354.                 ;SEND 64 BYTES TO DECODER (00).
  355. p7e:    mov ah,7eh              ;send procedure byte 7eh
  356.     call send               ;call the send routeen
  357.     mov bx,0                ;reset the memory pointer
  358. p7el:   mov ah,00               ;just send 00h for all bytes
  359.     call send               ;call the send byte routeen
  360.     inc bx                  ;bx=bx+1
  361.     cmp bx,40h              ;test for 64 bytes sent yet
  362.     jnz p7el                ;if not finished then get another one
  363.     call endproc            ;call the end of procedure routeen
  364.     ret
  365.  
  366.                 ;GET ONE BYTE FROM DECODER (NULL BYTE).
  367. p80:    mov ah,80h              ;send procedure byte 80h
  368.     call send               ;call the send routeen
  369.     call getb               ;get echo from decoder
  370.     call getb               ;call getbyte routeen for the 1 byte data
  371.     call endproc            ;call the end of procedure routeen
  372.     ret
  373.  
  374.                 ;SEND 64 BYTES TO DECODER (00).
  375. p82:    mov ah,82h              ;send procedure byte 82h
  376.     call send               ;call the send routeen
  377.     mov bx,0                ;reset the memory pointer
  378. p82l:   mov ah,00               ;just send 00h for all bytes
  379.     call send               ;call the send byte routeen
  380.     inc bx                  ;bx=bx+1
  381.     cmp bx,40h              ;test for 64 bytes sent yet
  382.     jnz p82l                ;if not finished then get another one
  383.     call endproc            ;call the end of procedure routeen
  384.     ret
  385.  
  386. endproc:                        ;SEND END PROCEDURE BYTE, THEN 00.
  387.     mov ah,90h              ;send 90 (end of procedure byte)
  388.     call send               ;call the send routeen
  389.     mov ah,00               ;send the last byte 00
  390.     call send               ;call the send routeen
  391.     ret
  392.  
  393. ;this routeen first waits for a DCD (reset) = 1 condition.
  394. ;then it sends the answer to reset (ATR) message.
  395. ;if at any time while sending, DCD goes to 0 (low), then it starts again.
  396.  
  397. reset:  mov di,0                ;i = 0, ATR string pointer to 0
  398.         mov bx,0                ;pointer = 0
  399. re1:    call test_key           ;call the keyboard for a key
  400.         mov dl,comport[bx]      ;setup dx for the com port value
  401.         mov dh,0                ;
  402.         mov ah,03               ;request status byte
  403.     int 14h                 ;call bios for status
  404.     and al,10000000b        ;test the DCD bit 
  405.     jnz reset               ;if DCD = 0 then reset pointer & start again 
  406.         mov ah,memrst[di]       ;get a data byte from ATR string [i]
  407.     call send               ;call the send routeen data in AH. 
  408.         inc di                  ;i = i + 1 
  409.         cmp di,010h             ;test if 16 bytes sent 
  410.     jz resret               ;if done, continue to the main program. 
  411.         jmp re1
  412. resret: ret                     ;reset successful, return to main program.
  413.  
  414. test_key:                       ;this routeen does a single key test.
  415.         mov ah,0bh              ;request for keyboard status
  416.         int 21h                 ;call dos
  417.         cmp al,0ffh             ;test for a key
  418.         jz end_all              ;if pressed jmp end all
  419.         ret                     ;no key, return
  420. end_all:mov ax,0                ;request exit
  421.         int 21h                 ;call dos and exit
  422.  
  423.  
  424. ; *************   DECRYPTING ALGORYTHM ROUTEEN HERE    *******************
  425.  
  426. DECRYPT:                        ;the result of the decoded message bytes 
  427.                 ;are placed into the answ bytes in memory.
  428.                 ;if any error occurs while decoding
  429.                 ;ie. checksum or digital signature error,
  430.                 ;then STATUS bits 1 or 2 are set.
  431.                 
  432.                                 ;this section clears all variable bytes
  433.     mov bx,00               ;set pointer 00
  434. varclr: mov al,00               ;clear byte
  435.     mov var[bx],al          ;clear bytes in variable list
  436.     inc bx                  ;pointer = pointer +1
  437.         cmp bx,8                ;test for 8 variable bytes cleared
  438.     jnz varclr              ;if not complete then do another
  439.  
  440.                 ;this section clears all 8 answer bytes
  441.     mov bx,00               ;set pointer 00
  442. ansclr: mov al,00               ;clear byte
  443.     mov answ[bx],al         ;clear bytes in answer bytes
  444.     inc bx                  ;pointer = pointer +1
  445.     cmp bx,8                ;test for 8 variable bytes cleared
  446.     jnz ansclr              ;if not complete then do another
  447.  
  448.  
  449. ;  *************   initial hashing  ************                                
  450.     
  451.         mov cx,0                ;i = 0 (cx used for i)                           
  452.                 ;set up IN for kernal calls, IN = msg[i].
  453. h1:     mov bx,cx               ;set up pointer with i
  454.     mov al,msg[bx]          ;copy msg[i] into al
  455.     mov bx,0                ;set pointer to 0
  456.         mov in[bx],al           ;IN = msg[i]
  457.     call kernal             ;call the kernal routeen
  458.     inc cx                  ;cx = cx + 1   
  459.         cmp cx,27               ;if 27 calls not completed, do another.
  460.     jnz h1                  ;loop if not done
  461.  
  462. ;*************   4 signature bytes hashing  ***********
  463.  
  464.                                 ;i (cx) = 27
  465.     mov bx,0                ;IN = 0
  466.         mov al,0                ;
  467.     mov in[bx],al           ;
  468.     mov ch,0                ;ch pointer high = 0                        
  469.  
  470. h2:     call kernal             ;call the kernal routeen
  471.     call kernal             ;''     ''      ''      ''
  472.     
  473.                 ;IN = msg[i]
  474.     mov bx,cx               ;set bx with i , where cx = i
  475.     mov al,msg[bx]          ;get message byte indexed to (i) into al
  476.     mov bx,0                ;set pointer to 0
  477.     mov in[bx],al           ;IN = msg[i]
  478.                  
  479.                 ;if answ[oi]<>msg[i] then set status flag
  480.     mov dl,oi[bx]           ;dl = oi
  481.     mov dh,0                ;clear high nibble of pointer
  482.     mov bx,dx               ;copy oi offset into pointer
  483.     mov ah,answ[bx]         ;copy answ[oi] into ah
  484.     mov bx,cx               ;set pointer to i
  485.     mov al,msg[bx]          ;copy msg[i] into al
  486.     cmp al,ah               ;test for answ[oi] <> msg[i]
  487.     jnz st1                 ;if <> set status flag for signature byte
  488.     jmp h3                  ;match found so all ok, continue       
  489.     
  490. st1:                            ;set the status flag
  491.     mov bx,0                ;set pointer to 0     
  492.     mov al,1                ;set bit 1
  493.     or  status[bx],al       ;logic or the status byte so set error1
  494.  
  495.                 ;oi=oi+1 then and with 7
  496. h3:     mov bx,0                ;set pointer to 0
  497.     mov al,1                ;increment value = 1
  498.     add oi[bx],al           ;oi = oi + 1 
  499.     mov al,7                ;set mask value 7
  500.     and oi[bx],al           ;mask out higher bits, limit count 0 - 7
  501.  
  502.     inc cl                  ;i = i + 1
  503.         cmp cl,31               ;test for i = 31
  504.     jnz h2                  ;if not completed, go again
  505.  
  506. ;****************   final 64 hashes on last byte ***************
  507.  
  508.     mov cx,0                ;i=0
  509. h4:     mov bx,0                ;set up IN for kernal calls
  510.  
  511. ;-----
  512. ;    ECM as from 24.5.95
  513.  
  514.         mov al,0dh              ;input data = 0dh
  515.         mov in[bx],al           ;copy data byte into in
  516. ;-----
  517.         call kernal             ;call the kernal routeen
  518.         inc cx                  ;i = i + 1
  519.         cmp cl,64               ;test for last call count
  520.     jnz h4                  ;if not complete, call another one
  521.  
  522.  
  523. ;***********   checksum testing here on last byte msg[31]  *******
  524.  
  525.                 ;B=0
  526.         mov bx,0                ;set pointer to 00
  527.     mov al,0                ;data = 0
  528.     mov b[bx],al            ;b=0
  529.  
  530.                 ;add msg[0..31] to B
  531.     mov cx,0                ;i=0
  532. addb:   mov bx,cx               ;set pointer to msg
  533.     mov al,msg[bx]          ;get msg[0..31] byte into al
  534.     mov bx,0                ;set pointer to 0
  535.     mov ah,b[bx]            ;get B byte into ah
  536.     add al,ah               ;add B to msg[0..31]
  537.     mov b[bx],al            ;store answer into B
  538.     inc cx                  ;i = i + 1
  539.     cmp cx,32               ;check if all 32 bytes in msg added to B
  540.     jnz addb                ;if not completed, add another
  541.  
  542.                 ;does B (now status) <> 0 ?
  543.     
  544.     mov al,b[bx]            ;get B into al
  545.     cmp al,0                ;test for 0
  546.     jnz st2                 ;if <> 0 then set error = st2
  547.     jmp maskout             ;jump maskout
  548.  
  549. st2:                            ;set status flag to 2
  550.     mov al,2                ;set data to error 2
  551.     or status[bx],al        ;logic or status with 2
  552.  
  553. maskout:                        ;mask out answ[7] hi nibble (not used)
  554.  
  555.     mov bx,7                ;set pointer to offset byte 7
  556.         mov al,0fh              ;set data to 0fh
  557.     and answ[bx],al         ;mask out high nibble of answ [7]
  558.     
  559.     ret                     ;hashing completed, now return to main.
  560.  
  561.  
  562. ;****************   critical kernal routeen   ****************        
  563.  
  564. kernal:                         ;this is the critical algorythm used to
  565.                 ;convert bytes into correct answer bytes.
  566.                 ;do not use cx (i) in this routeen.                         
  567.     
  568.                 ;answ[oi] = answ[oi] ex-or in.
  569.     mov bx,0                ;set pointer to 0
  570.     mov bl,oi[bx]           ;get oi into pointer low
  571.     mov bh,0                ;clear high byte of pointer
  572.     mov dx,bx               ;copy offset [oi] into dx for later  
  573.     mov al,answ[bx]         ;get answ[oi] into al
  574.     mov bx,0                ;set pointer to 0
  575.     xor al,in[bx]           ;ex-or answ[oi] with in
  576.     mov bx,dx               ;set pointer back to [oi]
  577.     mov answ[bx],al         ;result back in answ[oi]
  578.     
  579.                 ;upper nibble of answ[oi] as first pointer.
  580.     mov bx,0                ;set pointer to 0
  581.     mov al,oi[bx]           ;get oi into al
  582.     mov ah,0                ;clear high byte of pointer
  583.     mov bx,ax               ;set oi offset into bx
  584.     mov al,answ[bx]         ;get answ[io] into al
  585.     clc                     ;clear carry to insert a zero into bit 7
  586.     rcr al,1                ;rotate the answ[oi] byte 4 places right
  587.     clc                     ;
  588.     rcr al,1                ;making the hi nibble to low nibble
  589.     clc                     ;
  590.     rcr al,1                ;
  591.     clc                     ;
  592.     rcr al,1                ;
  593.     mov bx,0                ;set pointer to 00
  594.     add al,key[bx]          ;add card type offset to key pointer
  595.     mov bl,al               ;copy low nibble + offset into pointer low
  596.     mov bh,0                ;clear pointer high
  597.     mov dl,keytab[bx]       ;dl = key[ hi made low nibble of answ[oi] ]
  598.     
  599.                 ;lower nibble of answ[oi] + 16 as second. 
  600.     mov bx,0                ;set pointer to 0
  601.     mov al,oi[bx]           ;get oi into al
  602.     mov ah,0                ;clear high byte of pointer
  603.     mov bx,ax               ;set oi offset into bx
  604.     mov al,answ[bx]         ;get answ[io] into al
  605.     and al,0fh              ;mask out high nibble
  606.     add al,16               ;add 16 giving a +16 further offset 
  607.     mov bx,0                ;set pointer to 0
  608.     add al,key[bx]          ;add card type offset to key value
  609.     mov bl,al               ;low nibble + 16 + card type into pointer low
  610.     mov bh,0                ;clear pointer high
  611.     mov dh,keytab[bx]       ;dh = keys[ low nibble only + 16 ]
  612.  
  613.     add dl,dh               ;add both fetched keys bytes dl and dh
  614.     not dl                  ;complement dl (c)
  615.  
  616.                 ;rotate C to 1 left, bit 7 enters bit 0
  617.     rol dl,1                ;shift left 1 bit
  618.  
  619.                 ;C = C + in
  620.     mov bx,0                ;set pointer to 0
  621.     add dl,in[bx]           ;add in into C
  622.     
  623.                 ;rotate C to 3 right, bit 0 enters bit 7 
  624.     ror dl,1                ;shift right 3 bits
  625.     ror dl,1                ;
  626.     ror dl,1                ;
  627.  
  628.                 ;oi=oi+1 then and with 7
  629.     mov al,oi[bx]           ;copy oi into al
  630.     inc al                  ;oi = oi + 1
  631.     and al,7                ;and oi with 7 to limmit count
  632.     mov oi[bx],al           ;update oi
  633.                 
  634.                 ;answ[oi] = answ[oi] ex-or C.
  635.     mov al,oi[bx]           ;get oi into al
  636.     mov ah,0                ;clear high byte of pointer
  637.     mov bx,ax               ;set oi offset into bx
  638.     mov al,answ[bx]         ;get answ[oi] into al
  639.     xor al,dl               ;ex-or answ[oi] with C
  640.     mov answ[bx],al         ;result back in answ[oi]
  641.     ret                     ;return to hash function.
  642.  
  643.  
  644. diswords:                       ;display a string (used for text)
  645.         mov di,0                ;set pointer to 0
  646.         mov ah,09               ;request display
  647.         lea dx,comments[di]     ;set pointer to 'comments' memory
  648.         int 21h                 ;call DOS to diplay start screen
  649.         ret                     ;return
  650.  
  651. ;*************    data section     ***************************
  652.   
  653.     org memrst
  654. ;ATR message to decoder
  655. db 3fh,0fah,11h,25h,05h,00h,01h,0b0h,05h,3bh,34h,4dh,59h,00,81h,80h
  656.     
  657.     org mem7a
  658. ;on screen diagnosic text
  659. db 000h
  660. db "DSIG........CKSM........"
  661.  
  662.         org comments
  663.  
  664. db 10
  665. db" _______________________________________________________________",13,10
  666. db 10,10,10
  667. db"       FULL VERSION  V1.6 DECRYPTING INCLUDED (adult only).     ",13,10
  668. db"       *** ADULT CARD EMULATOR ****                             ",13,10
  669. db"           DATE: 31.5.95                                        ",13,10
  670. db"                                                                ",13,10
  671. db"       WARNING:: THIS PROGRAM MUST NOT BE USED OR COPIED IN     ",13,10
  672. db"                 ANY WAY, OTHER THAN FOR SELF EDUCATIONAL       ",13,10
  673. db"                 PURPOSES IN PROGRAMMING. USE OF THIS PROGRAM   ",13,10
  674. db"                 FOR FREE SKY VIEWING IS ILLEGAL.               ",13,10
  675. db"                 ============================================   ",13,10
  676. db 10,10
  677. db"     Press any key or AUTHORISE to EXIT...                      ",13,10
  678. db 10
  679. db" _______________________________________________________________",13,10
  680. db"$"
  681.  
  682.         org errortext
  683.  
  684. db 10,13
  685. db"Error - Com port number must be specified as  1,2,3 or 4.       ",13,10
  686. db"        eg. ADULTx 1t (where '1' selects com1.)                 ",13,10
  687. db"                      (where 't' is diagnostic Text enable.)    ",13,10
  688. db"$"
  689.              
  690.         org keytab
  691.  
  692.   db 048h, 09bh, 04dh, 0a6h, 0f9h, 0d9h, 0dfh, 06eh 
  693.   db 0ach, 084h, 0fah, 08bh, 02eh, 0b6h, 076h, 019h 
  694.   db 0c1h, 0b0h, 0a3h, 0bbh, 00ch, 0fdh, 070h, 072h 
  695.   db 0cah, 055h, 0efh, 0a0h, 07fh, 0bfh, 059h, 0adh 
  696.  
  697.  
  698.     
  699.     code ends 
  700.     end INIT
  701.